<template>
  <header class="header">
    <h1>todos</h1>
    <input
      class="new-todo"
      placeholder="What needs to be done?"
      autofocus
      @keydown.enter="addFn"
      v-model.trim="title"
    />
  </header>
</template>

<script>
export default {
data(){
    return{
        title:""
    }
},
 
  methods: {
    addFn() {
       if(!this.title){
           alert("请输入内容")
           return
       }
      this.$emit("add-todo",this.title);
      this.title=""
    },
  },
};
</script>

<style>
</style>